//
//  TabList.swift
//  onemeetingmac
//
//  Created by 张衡 on 2019/12/20.
//  Copyright © 2019 onemeeting. All rights reserved.
//

import Foundation


class TabList: MdView {
    
    var dataList:[String] = []
    
    override init(frame frameRect: NSRect) {
        super.init(frame: frameRect)
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func setupUI() {
        
        self.addSubview(maskView)
        maskView.snp.makeConstraints { (make) in
            make.edges.equalToSuperview()
        }
        
        self.addSubview(list)
        list.snp.makeConstraints { (make) in
            make.height.equalTo(100)
            make.left.equalToSuperview()
            make.bottom.equalToSuperview()
            make.width.equalTo(100)
        }
    }
    
    lazy var maskView: MSView = {
        let view = MSView()
        view.tap = { maskView in
            self.dismss()
        }
        return view
    }()
    
    lazy var list: NSTableView = {
        let tab = NSTableView.init(frame: NSRect.zero)
        tab.delegate = self
        tab.dataSource = self
        return tab
    }()
    
    func show()  {
        
        let inView =  self.window?.contentView
        inView?.addSubview(self)
        self.snp.makeConstraints { (make) in
            make.edges.equalToSuperview()
        }
    }
    
    func dismss()  {
        self.maskView.removeFromSuperview()
        self.list.removeFromSuperview()
        self.removeFromSuperview()
    }
    
}

extension TabList:NSTableViewDelegate,NSTableViewDataSource {
    func numberOfRows(in tableView: NSTableView) -> Int {
        return dataList.count
    }


    func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
        return nil
    }
}


